#include<stdio.h>
struct AddressBook
{
    char name[20];
    int birthday;
    char PhoneNumber[30];
};

typedef struct AddressBook AB;

void print(const AB *p)
{
	printf("%s %d %s\n", p->name, p->birthday, p->PhoneNumber);
}

int main()
{
    int n;
    scanf("%d", &n);
    AB friends[n];

    for(int i = 0; i < n ;i ++)
    {
        scanf("%s %d %s", friends[i].name, &friends[i].birthday, friends[i].PhoneNumber);
    }

    for(int i = 0; i < n - 1; i ++)
    {
        for(int j = 0; j < n - 1 - i; j ++)
        {
            if(friends[j].birthday > friends[j + 1].birthday)
            {
                AB t = friends[j];
                friends[j] = friends[j + 1];
                friends[j + 1] = t;
            }
        }
    }

    for(int i = 0; i < n; i ++)
    {
        print(&friends[i]);
    }

    return 0;
}
